PROJECT   =    FaceRec
OBJ       :=   Tools.o FaceRecDB.o
RES       :=   FaceRecMain.o

CXX       :=   g++
CC        :=   gcc
STRIP     :=   strip
PROTOC    :=   protoc

OUT_PATH    = ./out

# linking libraries
LIBS   = -ldl -lpthread

# linking libraries
LDFLAGS   = -m64 -L./lib -Wl,-rpath=./lib

CUR_DIR   =   $(shell pwd)
SRC       =   $(CUR_DIR)/src
BUILD     =   $(CUR_DIR)/build
VPATH     =   $(SRC)

# -DUSE_LIBYUV -DUSE_TURBOJPEG -DUSE_OPENCV
CFLAGS    := -m64 -O2 -ftree-vectorize -mavx -msse -msse2 -msse3 -Wall -I./include -Wpointer-arith -std=c++11 -ffast-math -fsigned-char -DUSE_UUID -DENABLE_DEBUG_PRINT=1
# CFLAGS    := -m64 -g -fno-inline -Wa,-adlhn -Wall -I./include -Wpointer-arith -std=c++11 -ffast-math -fsigned-char -DUSE_UUID -DENABLE_DEBUG_PRINT=1

all: $(BUILD) $(PROJECT)

$(PROJECT): $(OBJ) $(RES)
	$(CXX) $(CFLAGS) $(addprefix $(BUILD)/, $^) -o $(OUT_PATH)/$@ $(LDFLAGS) -Wl,--start-group  -Wl,-Bstatic -luuid -Wl,-Bdynamic $(LIBS) -Wl,--end-group
#	$(STRIP) $(OUT_PATH)/$(PROJECT)

%.o : %.cc
#	$(CXX) -c $(CFLAGS) $< -o $(BUILD)/$@
	$(CXX) -c $(CFLAGS) $< -o $(BUILD)/$@ > $(BUILD)/$@.S

clean:
	$(RM) -r $(BUILD)
	$(RM) $(OUT_PATH)/$(PROJECT)

$(BUILD) : 
	-mkdir -p $@
